package cn.zwx.member.svc.controller.captcha;

import cn.zwx.base.entity.ResponseEntity;
import cn.zwx.base.exception.BizWrapException;
import cn.zwx.member.svc.vo.GenCaptchaVO;
import cn.zwx.member.svc.service.CaptchaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangwenxue
 */
@RestController
@Api(tags = "验证码相关接口")
@RequestMapping("/captcha")
public class CaptchaController {

    private final CaptchaService captchaService;

    public CaptchaController(CaptchaService captchaService) {
        this.captchaService = captchaService;
    }

    /**
     * 生成验证码图片
     * @return 返回验证码信息
     */
    @PostMapping("/get")
    @ApiOperation("生成验证码图片")
    public ResponseEntity<GenCaptchaVO> getCaptcha() throws BizWrapException {
        GenCaptchaVO captchaVO =  captchaService.getCaptcha();
        return ResponseEntity.success(captchaVO);
    }

}
